import { Component, OnInit } from '@angular/core';
import { UserInfoService } from "./user-info.service"
import { Router } from "@angular/router";

@Component({
    selector: 'app-user-info',
    templateUrl: './user-info.component.html',
    styleUrls: ['./user-info.component.scss']
})
export class UserInfoComponent implements OnInit {

    userInfo = {
        nickName : "",
        avatar : ""
    };

    constructor(
        private userInfoService: UserInfoService,
        private router : Router
    ) { }

    ngOnInit() {
        this.userInfo = JSON.parse(localStorage.getItem("userInfo"));
    }

    loginOut(): void {
        this.userInfoService.loginOut().subscribe(res => {
            localStorage.removeItem("userInfo");
            localStorage.removeItem("token");
            this.router.navigate(['login']);
        })
    }

    // 修改密码
    editPassword(){
        this.router.navigate(['/center/password']);
    }

}
